﻿using MediatR;
using PersonnelManagement.Application.Command.PostCommand;
using PersonnelManagement.Domain.PersonnelDomain;
using PersonnelManagement.Infrstructre.Interface;

namespace PersonnelManagement.Application.CommandHandler.PostCommandHandler
{
    /// <summary>
    /// 岗位
    /// </summary>
    public class PostListCommandHandler : IRequestHandler<PostListCommand, List<Post>>
    {
        /// <summary>
        /// 岗位
        /// </summary>
        IPostRepository pRep;

        public PostListCommandHandler(IPostRepository pRep)
        {
            this.pRep = pRep;
        }


        public async Task<List<Post>> Handle(PostListCommand request, CancellationToken cancellationToken)
        {

            var list = (await pRep.Getall()).Where(c => c.SectorId == request.SectorId);
            return list.ToList();

        }
    }
}
